/**
 * Created by xxcao on 2017/6/5.
 */

var express = require('express');
var router = express.Router();
var util = require('../util/util');
var boardDao = require('../dao/boardDao');

//获取我的看板
router.get('/getBoards', function(req, res, next) {
    if(util.removeFavicon(req,res)) {
        util.logInfo(0, 'board/getBoards', 'GET', req.query);
        boardDao.getBoards(req, res, next);
    }
});

//创建看板
router.post('/create',function (req, res, next) {
    if(util.removeFavicon(req,res)) {
        util.logInfo(0, 'board/create', 'POST', req.body);
        boardDao.add(req, res, next);
    }
});

//退出看板
router.post('/exit',function (req, res, next) {
    if(util.removeFavicon(req, res)) {
        util.logInfo(0, 'board/exit', 'POST', req.body);
        boardDao.exit(req, res, next);
    }
});

//解散看板
router.post('/dismiss', function (req, res, next) {
    if(util.removeFavicon(req, res)) {
        util.logInfo(0, 'board/dismiss', 'POST', req.body);
        boardDao.delete(req, res, next);
    }
});

//置顶看板
router.post('/top', function (req, res, next) {
    if(util.removeFavicon(req, res)) {
        util.logInfo(0, 'board/top', 'POST', req.body);
        boardDao.top(req, res, next);
    }
});

//免打扰看板
router.post('/disturb', function (req, res, next) {
    if(util.removeFavicon(req, res)) {
        util.logInfo(0, 'board/disturb', 'POST', req.body);
        boardDao.disturb(req, res, next);
    }
});

//获取看板详情
router.get('/detail',function (req, res, next) {
    if(util.removeFavicon(req, res)) {
        util.logInfo(0, 'board/detail', 'GET', req.query);
        boardDao.detail(req, res, next);
    }
});

//邀请进看板
router.post('/join',function (req, res, next) {
    if(util.removeFavicon(req, res)) {
        util.logInfo(0, 'board/join', 'POST', req.body);
        boardDao.addMember(req, res, next);
    }
});

//修改名称
router.put('/boardName',function (req, res, next) {
    if(util.removeFavicon(req, res)) {
        util.logInfo(0, 'board/boardName', 'PUT', req.body);
        boardDao.updateName(req, res, next);
    }
});

//修改备注
router.put('/boardRemark',function (req, res, next) {
    if(util.removeFavicon(req, res)) {
        util.logInfo(0, 'board/boardRemark', 'PUT', req.body);
        boardDao.updateRemark(req, res, next);
    }
});

//修改字体大小
router.put('/noteSize',function (req, res, next) {
    if(util.removeFavicon(req, res)) {
        util.logInfo(0, 'board/noteSize', 'PUT', req.body);
        boardDao.updateNoteSize(req, res, next);
    }
});

module.exports = router;